package Function.ItemUse;

import VWorldGameStudio.*;
import VWorldGameStudio.events.DoorEvent;

import static FCRendering.FCRMaster.*;

//开门神器
public class ToolBanShou extends AItemUse{
    @Override
    public ItemUseResult directUse() {
        return new ItemUseResult().useless();
    }

    @Override
    public ItemUseResult useInMapTarget(int x, int y) {
        String blockname = mapLib.getMapOfName(player1.getMapname())
                .getPlaceNameOfCoor(x, y);
        if (blockname.startsWith("Men")) {
            //是门
            FCEvent mayBeDoor = eventLib.getEventOfName(mapLib.getMapOfName(player1.getMapname())
                    .getEventNameOfCoor(x, y));
            if (mayBeDoor instanceof DoorEvent) {
                //是门，判断有没有钥匙吧,或者已经开过了，
                    fcv.closeAllShowWindw();
                    if (!gameSave.getSaveAllHasUnLockDoors().contains(mayBeDoor.getName())) {
                        //TODO 这个门还没开过的
                        //相同的钥匙
                        gameSave.getSaveAllHasUnLockDoors().add(mayBeDoor.getName());
                    }
                    ItemUseResult result = new ItemUseResult();
                    result.resultString.add("使用了扳手，门开了");
                    fcv.getMessage().add("使用了扳手，门开了");
                    fcv.showMessage();
                    if (!fcrMaster.isIsplayopendoormusic()) {
                        fcrMaster.setOpendoorx(x);
                        fcrMaster.setOpendoory(y);
                        fcrMaster.setIsplayopendoormusic(true);
                        sound.setEffectSound(16);
                    }
                    return result;
            }
        }
        return new ItemUseResult().useless();
    }

    @Override
    public ItemUseResult useForMonsterTarget(FCBattleOrder battleOrder, FCMonster m) {
        fcv.getMessage().add("什么也没发生");
        fcv.showMessage();
        return new ItemUseResult().useless();
    }

    @Override
    public ItemUseResult useForPlayerTarget(FCPlayerInfo p) {
        fcv.getMessage().add("什么也没发生");
        fcv.showMessage();
        return new ItemUseResult().useless();
    }

    @Override
    public ItemUseResult useForTankTarget(FCTank t) {
        fcv.getMessage().add("什么也没发生");
        fcv.showMessage();
        return new ItemUseResult().useless();
    }
}
